AsistenciaTecnica = function(){
	var configWindow = {
			add: "sugerenciaAgregarTop",
			edit: "sugerenciaEditarTop",
			save: "sugerenciaGuardarTop",
			remove: "sugerenciaEliminarTop",
			grid: "sugerenciaGrid",
			form: "sugerenciaForm"
		};
		var configWindowBottom = {
				add: "sugerenciaAgregarBottom",
				edit: "sugerenciaEditarBottom",
				save: "sugerenciaGuardarBottom",
				remove: "sugerenciaEliminarBottom"
		};
		return {
			agregarAsistenciaTecnica: function(){
				Asi.form.switchButton(configWindow, "add");
				Asi.form.switchButton(configWindowBottom, "add");
//				Ext.getCmp("sugerenciaFechaNacimiento").allowEnable = true;
			},
			editarAsistenciaTecnica: function(){
				Asi.form.switchButton(configWindow, "edit");
				Asi.form.switchButton(configWindowBottom, "edit");
			},
			eliminarAsistenciaTecnica: function(){
				Asi.message.confirmDelete(function(){
					Asi.message.progress("Eliminando Informaci\u00F3n...");
					Ext.Ajax.request({
						timeout: Asi.constants.TIMEOUT_SECONDS,
						url: Asi.constants.CONTEXT_PATH + "/sugerencia/delete",
						params: {
							sugerenciaId: Asi.utils.getValue("sugerenciaId")
						},
						callback: function(options, success, response){
							Ext.Msg.hide();
							if(success){
								var jsonObject = Asi.utils.ajaxRequestGetJson(response);
								if(jsonObject && jsonObject.success){
									Asi.form.switchButton(configWindow, "remove");
									Asi.form.switchButton(configWindowBottom, "remove");
									Asi.message.alert(jsonObject.message);
									Asi.form.clearAndDisable("sugerenciaForm");
									if(jsonObject.sugerencias){
				    					Ext.getCmp("sugerenciaGrid").getStore().loadData(jsonObject.sugerencias);
									}
									return;
								}
								jsonObject = jsonObject || {};
								Asi.message.alertInvalid(jsonObject.message || Asi.constants.DEFAULT_ERROR_MESSAGE);
								return;
							}
							Asi.message.alertInvalid(Asi.constants.DEFAULT_ERROR_MESSAGE);
						}
					});
				});
			},
			validacionIngresodeNuevoInventario: function(){
				var i = 0;
				var gridCompra = Ext.getCmp("sugerenciaGrid");
				var gridData = 0;
				Ext.each(gridCompra.getStore().getRange(), function(){
					if(Ext.getCmp("sugerenciaGrid").getStore().getRange()[i].data.materiaPrimaId == Ext.getCmp("materiaPrimaIdDos").getValue()){
						gridData = 1;
					}
					i++;
	          });
				return gridData;
			},
			guardarAsistenciaTecnica: function(){
				
				
				Asi.message.progress("Guardando Informaci\u00F3n...");
				Ext.getCmp("sugerenciaForm").getForm().submit({
	    			url: Asi.constants.CONTEXT_PATH + "/empleado/sugerenciaSave",
	    			timeout: Asi.constants.TIMEOUT_SECONDS,
	    			params: {
	    				
	    			},
	    			success: function(form, action){
	    				Asi.form.switchButton(configWindow, "save");
	    				Asi.form.switchButton(configWindowBottom, "save");
	    				Asi.message.alert(action.result.message);
	    				Asi.form.setDisable("sugerenciaForm", true);
	    				if(action.result.sugerenciaes){
	    					Ext.getCmp("sugerenciaGrid").getStore().loadData(action.result.sugerenciaes);
	    					Ext.getCmp("sugerenciaGrid").getSelectionModel().select(action.result.sugerenciaIndex);
	    				}
	    			},
	    			failure: Asi.form.failureProcedure
	   			});
				
				
			},
			init: function(config){
				var sugerenciaData = config.sugerencia;
				var configToReturn = {};
				configToReturn.items = [];
				configToReturn.menu = AsiBotones.getBotones(AsiGen.getTipoUsuario(), AsiGen.getPantallaId());
				configToReturn.items.push({
					flex: 1,
					title: "CONTROL DE LAS SUGERENCIAS Y CHAT",
					autoScroll: true,
					xtype: "panel",
					layout: {
					    type: "vbox",
					    align : "center",
					    pack  : "start"
					},
					defaults: {width: 730, margins: "5 0 5 0"},
					dockedItems: [
						{
							
							xtype: "toolbar",
							dock: "top",
//							hidden: AsiKYC.getKycVigente() === false,
							items: [
							   '->',
							   {
						    	   text: "Editar",
						    	   id: "sugerenciaEditarTop",
								   iconCls: Asi.constants.icons.EDIT_ICON,
								   handler: AsistenciaTecnica.editarAsistenciaTecnica
						       },{
						    	   text: "Guardar",
						    	   id: "sugerenciaGuardarTop",
								   iconCls: Asi.constants.icons.SAVE_ICON,
								   handler: AsistenciaTecnica.guardarAsistenciaTecnica
						       }
						    ]
						},{
							
				        	xtype: "toolbar",
				        	dock: "bottom",
//				        	hidden: AsiKYC.getKycVigente() === false,
				        	bodyStyle: "border: solid",
				        	items: [
				        	   '->',
				        	   {
						    	   text: "Editar",
						    	   id: "sugerenciaEditarBottom",
								   iconCls: Asi.constants.icons.EDIT_ICON,
								   handler: AsistenciaTecnica.editarAsistenciaTecnica
						       },{
						    	   text: "Guardar",
						    	   id: "sugerenciaGuardarBottom",
								   iconCls: Asi.constants.icons.SAVE_ICON,
								   handler: AsistenciaTecnica.guardarAsistenciaTecnica
						       }
			        	    ]
				        }
		            ],
					items: [
					       
						{
							xtype: "form",
						id: "ContenedorPrincipal",
						flex: 1,
						autoScroll: true,
						items: [
					        
					        
					        
//--------------------------------------------------------------------------------------------------------  INICIO DE GRID, PEDIDOS TERMINADOS Y LISTOS PARA ASIGNARLES INSTALADORES PARA TERMINAR SU FLUJO DE TRABAJO    
				        
						

//-------------------------------------------------------------------------------------------------------- INICIO FORM

							//-----------------------------------------chat-------------------------------------------------------------
								
							//------------------------------------------grid--------------------------
												
											
												{
												  	title: "LISTA DE SUGERENCIAS DE LOS CLIENTES",
													xtype: "grid",
													id: "sugerenciaGrid",
													height: 150,
													minHeight: 150,
													collapsible : true,
													collapsed:false,
													store: new Ext.data.SimpleStore({
												    	data: sugerenciaData || [],
												    	fields: [
												    	         
												    	    "sugerenciaId",
												    	    "detalleSugerencia",
												    	    "usuario",
															"fechaSugerencia",
															"estadoSugerencia",
															
														
										    	        ]
												    }),
												    columns: [
												        {header: "Numero De La Sugerencia",  dataIndex: "sugerenciaId", flex:1, width: 120},
												        {header: "Detalle De La Sugerencia",  dataIndex: "detalleSugerencia", flex:1, width: 120},
											            {header: "Usuario",  dataIndex: "usuario", flex:1, minWidth: 120},
											            {header: "Fecha De Sugerencia",  dataIndex: "fechaSugerencia", flex:1, width: 120},
											           
											            

												    ],listeners: {
												    	selectionchange: function(model, records){
												    		if(!records || records.length <= 0) return;
												    		var record = records[0];
												    		if(record != null){

												    			Asi.form.setValues("sugerenciaForm", record.data);
												    			Asi.form.setDisable("sugerenciaForm");
												    		}
												    		Asi.form.switchButton(configWindow, "rowclick");
												    		Asi.form.switchButton(configWindowBottom, "rowclick");
												    	},
												    	afterrender: function(){
												    		if(this.store.data.items.length > 0) Asi.grid.selectFirstRow(this);
												    		Asi.form.switchButton(configWindow, "cancelNotClear");
												    		Asi.form.switchButton(configWindowBottom, "cancelNotClear");
												    	}
												    }
												},
												
												
												{
										        	xtype: "form",
													id: "sugerenciaForm",
													flex: 1,
												    border: false,
												    autoScroll: true,
													layout: {
														type: "table",
														columns: 6,
														style : {
															width : "730px",
															"margin-top" : "5px",
															"margin-bottom" : "40px"
														},
														align : "center"
													},
													defaults: {
														width: 230,
														selectOnFocus: true,
														enforceMaxLength: true,
														maxLength: 200,
														typeAhead: true,
														minChars: 1,
														queryMode: "local",
														forceSelection: true,
														allowEnable: true,
														colspan: 2
													},
													items: [
											        	 {	
															xtype: "label",
															text: "SUGERENCIA DE CLIENTE",
															cls: "x-form-item label_header",
															colspan: 8,
															width: 730
														},
														{xtype: "label", text: "Usuario", cls: "x-form-item label_spacing"},
														{xtype: "label", text: "Fecha", cls: "x-form-item label_spacing"},
														{xtype: "label", text: "Estado", cls: "x-form-item label_spacing"},
														{
															xtype: "textfield",
															id: "usuario",
														},{
															xtype: "textfield",
															id: "fechaSugerencia",
														},{
															xtype: "combo",
															id: "estadoSugerencia",
															name: "sugerencia.estadoSugerencia",
															colspan: 3,
															store: new Ext.data.SimpleStore({
																data: Asi.combos.yesnoArray() || [],
																fields: [
																         "id",
																         "descripcion"
																        ]
															}),
															displayField: "descripcion",
															valueField: "id",
															allowBlank: false
														},
														{xtype: "label", text: "DetalleSugerencia", cls: "x-form-item label_spacing"},
														{xtype: "label", text: "", cls: "x-form-item label_spacing"},
														{xtype: "label", text: "", cls: "x-form-item label_spacing"},
														{
															xtype: "textarea",
															colspan: 8,
															width: 730,
															id: "detalleSugerencia",
														},
														{
															xtype: "hidden",
															id: "sugerenciaId",
															name: "sugerencia.sugerenciaId"
														}
														
														
														
														
														

													]
										        },
												
					  //------------------------------------mapa------------------------------------------------
												
				        {
						    xtype: 'panel',
						    title: 'MAPA DE INSTALACION',
						    cls: "x-form-item label_header",
						    html:'<iframe src="https://www.google.com/maps/embed?pb=!1m14!1m12!1m3!1d1231.4711461955617!2d-89.21126827598314!3d13.712035275036385!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!5e1!3m2!1ses!2ssv!4v1410386944221" width="400" height="300" frameborder="0" style="border:0"></iframe>',
						    layout: 'fit',
						    align: 'center',
						    flex: 1
				        },
				        {
							xtype : 'panel',
							title: 'CHAT',
							id : 'first_block',
							html : 
								'<div id="cboxdiv" style="text-align: center; line-height: 0"><div><iframe frameborder="0" width="500" height="204" src="http://www3.cbox.ws/box/?boxid=3410533&amp;boxtag=a7jqew&amp;sec=main" marginheight="2" marginwidth="2" scrolling="auto" allowtransparency="yes" name="cboxmain3-3410533" style="border:#636C75 1px solid;" id="cboxmain3-3410533"></iframe></div><div><iframe frameborder="0" width="400" height="96" src="http://www3.cbox.ws/box/?boxid=3410533&amp;boxtag=a7jqew&amp;sec=form" marginheight="2" marginwidth="2" scrolling="no" allowtransparency="yes" name="cboxform3-3410533" style="border:#636C75 1px solid;border-top:0px" id="cboxform3-3410533"></iframe></div></div>'
						},
				        
				        
				        
				        
				    
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				        
				      ]} 
				        
				        
				        
				    ]
					
				});
				return configToReturn;
			}
		};
	}();